package org.uned.agonzalo16.bitacora.domain;

import java.util.Date;

import org.apache.commons.lang3.builder.HashCodeBuilder;

import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;

public abstract class BaseEntity {

	@Id
	protected Long id;

	@Index
	protected Date creationDate;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof BaseEntity)) {
			return false;
		}

		BaseEntity entity = (BaseEntity) obj;
		return id.equals(entity.getId());
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(id).build();
	}

}
